package com.houdoudou.bean;

public class Customer {

	String telnum="";
	String spareTelnum="";
	String secret="";
	String paySecret="";
	double money=-1;
	
	
	public Customer() {
		
	}
	public String getTelnum() {
		return telnum;
	}
	public void setTelnum(String telnum) {
		this.telnum = telnum;
	}
	
	public String getSpareTelnum() {
		return spareTelnum;
	}
	public void setSpareTelnum(String spareTelnum) {
		this.spareTelnum = spareTelnum;
	}
	public String getSecret() {
		return secret;
	}
	public void setSecret(String secret) {
		this.secret = secret;
	}
	public String getPaySecret() {
		return paySecret;
	}
	public void setPaySecret(String paySecret) {
		this.paySecret = paySecret;
	}
	public double getMoney() {
		return money;
	}
	public void setMoney(double money) {
		this.money = money;
	}
	
	public static void  merge(Customer customerExist,Customer customerGiven){
		if(!customerGiven.getSecret().isEmpty()){
			customerExist.setSecret(customerGiven.getSecret());
		}
		if(!customerGiven.getPaySecret().isEmpty()){
			customerExist.setPaySecret(customerGiven.getPaySecret());
		}
		if(!customerGiven.getSpareTelnum().isEmpty()){
			customerExist.setSpareTelnum(customerGiven.getSpareTelnum());
		}
		if(customerGiven.getMoney()!=-1){
			customerExist.setMoney(customerGiven.getMoney());
		}
	}
	
	   public  static Customer encrypt(Customer customer) throws Exception{
			String cipertext= PasswordUtil.encrypt(customer.getSecret());
			customer.setSecret(cipertext);	   
		   return customer;
	   }
	   public  static Customer decrypt(Customer customer) throws Exception{
	 		String plaintext= PasswordUtil.decrypt(customer.getSecret());
	 		customer.setSecret(plaintext);	   
	 	   return customer;
	    }
	   public  static Customer transEncrypt(Customer customer) throws Exception{
			String cipertext= TransPasswordUtil.encrypt(customer.getSecret());
			customer.setSecret(cipertext);	   
		   return customer;
	  }
	  public  static Customer transDecrypt(Customer customer) throws Exception{
			String plaintext= TransPasswordUtil.decrypt(customer.getSecret());
			customer.setSecret(plaintext);	   
		   return customer;
	   }
public static void print(String when ,Customer customer){
	
	System.out.println(when + "customerBean: telnum= "+customer.getTelnum()+"  secrete="+customer.getSecret()+"  paySecret="+customer.getPaySecret()
			+" spareTelnum="+customer.getSpareTelnum()+" money="+ customer.getMoney());
}

}
